package servlet;


import dao.entity.ManagerDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "managerDeleteServlet", value = "/delM")
public class ManagerDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取数据
        String mgid = request.getParameter("mgid");

        //调用相应的方法,执行删除操作
        ManagerDaoImpl mdi = new ManagerDaoImpl();
        int n = mdi.deleteManager(mgid);
        if(n!=0){
            //删除成功
            request.setAttribute("message","删除成功");
        }else {
            //删除失败
            request.setAttribute("message","删除失败");
        }
        request.getRequestDispatcher("result.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
